﻿@model KPIS.GERP.Models.SYS.ApprovalTask

@{
    ViewBag.Title = Model != null ? "ข้อมูลในคำขออนุมัติ" : "รายละเอียดข้อความ"; 
    if(ViewBag.NoLayout == true)
    {
        Layout = "~/Views/Shared/_EmptyLayout.cshtml";
    }
     
    //var firstRuleApproveType = ruleApproveTypeList.FirstOrDefault(o => Model != null && Model.CurrentRuleApprove != null && o.rule_approve_type_seq == Model.CurrentRuleApprove.rule_approve_type_seq);
    //KPIS.GERP.SERVICE.Model.rule_approve_group firstRuleApproveGroup = null;
    //if (firstRuleApproveType != null)
    //{
    //    firstRuleApproveGroup = ruleApproveGroupList.FirstOrDefault(o => o.rule_approve_group_seq == firstRuleApproveType.rule_approve_group_seq);
    //}
    //var controllerBackName = ""; var actionBackName = "";
    //if (firstRuleApproveGroup != null)
    //{
    //    controllerBackName = firstRuleApproveGroup.ref_controller_name;
    //    actionBackName = firstRuleApproveGroup.ref_action_name;
    //}  
}

    @Html.AntiForgeryToken() 
    
    @if (!string.IsNullOrWhiteSpace(ViewBag.MessageFromTakeAction))
    {
        <div class="alert alert-block alert-error" 
            title="Remark: exception message as following: @ViewBag.MessageFromTakeActionHide">
            <button type="button" class="close" data-dismiss="alert">
                <i class="icon-remove"></i>
            </button>
            @Html.Raw(System.Web.HttpUtility.HtmlDecode(ViewBag.MessageFromTakeAction))
        </div>
    } 
    <div class="block-button-menu-above">
        <a class="btn button-standard-width btn-small btn-gray" data-rel="tooltip" href="#" 
           onclick="window.location.href='@Url.Action("TaskMessageInbox", new { ruleApproveGroupSeq = ViewBag.RuleApproveGroupSeq, noLayout = ViewBag.NoLayout })'" role="button">
            <i class="icon-reply bigger-120"></i>&nbsp;&nbsp;กลับไปหน้าแสดงข้อมูลทั้งหมด
        </a>
    </div>  
    @Html.Partial("_DetailsForm", Model)

    @*@if (!string.IsNullOrWhiteSpace(actionBackName) && !(CompareUtility.IsObjectToStringEqual(actionBackName, "Home") && CompareUtility.IsObjectToStringEqual(controllerBackName, "Index")))
    {
        <iframe id="iframe1" src='@Url.Action(actionBackName, controllerBackName, new { id = Model.RefSeq, nolayout = true, EmptyLayout = true })' frameborder="0" style="width: 100%;" ></iframe>
    }
    @*Html.RenderAction("_EditorForm", "PrePurchase", new {id=Model.ReferenceEntitySeq});*@
    @Html.ValidationSummary(true, KPIS.GERP.Models.Class.ValidateText.RequiredField, new { @class = "alert alert-error" })
 

@section scripts
{
    <script>
        $("form").not("#formsearch").submit(function (e) {
            e.preventDefault();
            var currentForm = this;
            bootbox.confirm("ท่านต้องการยืนยัน ใช่หรือไม่", function (result) {
                if (result) {
                    currentForm.submit();
                }
            });
            

        });
        $(function () {
            var lastHeight1 = 0, curHeight1 = 0, $frame1 = $('#iframe1');
            setInterval(function () {
                curHeight1 = $frame1.contents().find('body').height() + 20;
                if (curHeight1 != lastHeight1) {
                    $frame1.css('height', (lastHeight1 = curHeight1) + 'px');
                }
            }, 500); 

            $("#btnShowHide").click(function () {
                $("#paragraph").slideToggle();
            });
            
            $("#pleaseFillReasons").hide();
            $("#Reasons").hide();
            $("#pleaseFillReasonsCaption").hide();
            // Smooth scroll
            $('#go_to_related_info').on('click', function (e) {
                e.preventDefault(); 
                var target = this.hash,
                $target = $(target);
                $target = $('#related_info');

                $('html, body').stop().animate({
                    'scrollTop': $target.offset().top
                }, 500, 'swing', function () {
                    window.location.hash = target;
                });
            });
        });

        function checkRemarks() {
            var remarks = $("#Reasons").val();
            if(remarks == undefined || remarks == "") {
                $("#pleaseFillReasons").show();
                $("#Reasons").show();
                $("#pleaseFillReasonsCaption").show();
                return false;
            }
            return true;
        }
    </script>
}